//
//  OMPersonalAvatarTableCell.m
//  OMENGO
//
//  Created by 梁尚嘉 on 2017/1/10.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMPersonalAvatarTableCell.h"

@interface OMPersonalAvatarTableCell ()
@property (nonatomic, strong) UILabel *elementLabel;
@property (nonatomic, strong) UIImageView *avatarImageView;
@end

@implementation OMPersonalAvatarTableCell

- (void)configure
{
    [super configure];
    [self.contentView addSubview:self.elementLabel];
    [self.contentView addSubview:self.avatarImageView];
    [self makeConstraints];

    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

- (void)configureCellWithObj:(OMAccount *)account
{
    [self.avatarImageView kt_imageWithURLStr:account.avatar placeHolder:nil withSize:CGSizeZero];
}

- (void)makeConstraints
{
    [self.elementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.top.bottom.equalTo(@0);
    }];

    [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(200)));
        make.bottom.equalTo(@(SM_SIZE(-30)));
        make.top.equalTo(@(SM_SIZE(30)));
        make.width.equalTo(self.avatarImageView.mas_height);
    }];
}

- (UIImageView *)avatarImageView
{
    if (!_avatarImageView) {
        _avatarImageView = [UIImageView new];
        _avatarImageView.layer.cornerRadius = SM_SIZE(60);
        _avatarImageView.clipsToBounds = YES;
    }
    return _avatarImageView;
}

- (UILabel *)elementLabel
{
    if (!_elementLabel) {
        _elementLabel = [UILabel new];
        _elementLabel.font = SM_CFont(32);
        _elementLabel.textColor = SM_darkGrayColor;
        _elementLabel.text = @"头像";
    }
    return _elementLabel;
}

+ (CGFloat)cellHeight
{
    return SM_SIZE(180);
}
@end
